#include <iostream>
#include "contacts.pb.h"
#include <string>

int main()
{
    std::string str;

    contacts::PeopleInfo person;
    person.set_name("张三");
    person.set_age(20);
    bool ret = person.SerializeToString(&str);
    if (ret == false)
        std::cout << "序列化失败" << std::endl;

    std::cout << "序列化成功,str: " << str << std::endl;

    {
        contacts::PeopleInfo person;
        bool ret = person.ParseFromString(str);
        if (ret == false)
            std::cout << "反序列化失败" << std::endl;

        std::cout << "反序列化成功" << std::endl;
        std::cout << "name: " << person.name() << std::endl;
        std::cout << "age: " << person.age() << std::endl;
    }

    return 0;
}